home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / cbm / 2137 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.9 KB

  1. Path: severus.mbfys.kun.nl!rhialto
  2. From: rhialto@mbfys.kun.nl (Olaf Seibert)
  3. Newsgroups: comp.sys.cbm
  4. Subject: Re: CHRGET routine on the C=64
  5. Date: 7 Feb 1996 20:56:27 GMT
  6. Organization: University of Nijmegen, The Netherlands
  7. Distribution: world
  8. Message-ID: <4fb3lr$ecs@wn1.sci.kun.nl>
  9. References: <s10f1bfd.037@shands.ufl.edu>
  10. NNTP-Posting-Host: severus.mbfys.kun.nl
  11.  
  12. In <s10f1bfd.037@shands.ufl.edu> mello.med@shands.ufl.edu writes:
  13.  
  14. |I want to incorporate some of my own routines into BASIC.  The
  15. |C=64 Programmer Reference Guide is not much help.  This is all I
  16. |could find on it:
  17. |
  18. |CHRGET routine is used by BASIC to get each character/token. 
  19. |This makes it simple to add new BASIC commands....  A common way
  20. |to use this method is to specify a character (@ for example)
  21. |which will occur before any of the new commands.  The new CHRGET
  22. |routine will search for the special character.  If none if
  23. |present, control is passed to the normal BASIC CHRGET routine. 
  24. |If the special character is present, the new command is
  25. |interpreted and executed by your machine language program.  This
  26. |minimizes the extra execution time added by the need to search
  27. |for additional commands.  This technique is often called a wedge.
  28. |
  29. |Now, I understand this means that when you RUN a program, CHRGET
  30. |will search the BASIC RAM and look for your special symbol in
  31. |addition to all the regular commands.  Is this a correct
  32. |assumption?  My question is:   (1) How do I change the vector
  33. |from the normal CHRGET routine to point to my CHRGET routine to
  34. |search through RAM for my @ of whatever else it will be.  (2)
  35. |Where in memory do I store my CHRGET routine and the routine
  36. |after the @ to be executed.  
  37.  
  38. 1: CHRGET is itself in RAM, so you can change it in-place. Here is
  39. a fragment from the PET memory map (C64 addresses vary slightly):
  40.  
  41.  CHRGET 0070-0087       112-135 Subroutine: Get Next Byte of BASIC Text
  42.  CHRGOT 0076            118     Entry to Get Same Byte of Text Again
  43.  TXTPTR 0077-0078       119-120 Pointer: Current Byte of BASIC Text
  44.         0070                    INC $77 BNE $0076 INC $78
  45.         0076                    LDA $xxxx CMP #$3A BCS $0087
  46.                                 CMP #$20 BEQ $0070 SEC SBC #$30 SEC SBC #$D0
  47.         0087                    RTS
  48.                                 C=1 for digits, Z=1 for end of statement/line
  49.  
  50. 2: There are basically 2 ways to patch CHRGET. One at the start, and
  51. one somewhere after CHRGOT. You place a JMP to your code at the desired
  52. location, which first does the work that CHRGET or CHRGOT normally does.
  53. Then, it checks if your special character has been found and if so, it
  54. acts on it.
  55.  
  56. |Any help with this problem would be greatly appreciated :-)
  57. |
  58. |If you could please respond by e-mail to mello.med@shands.ufl.edu
  59. |because I don't have access to a newsreader as of yet.
  60.  
  61. Done.
  62.  
  63. |Thanks >Steve M.
  64. -Olaf.
  65. --
  66. ___ Olaf 'Rhialto' Seibert      rhialto@mbfys.kun.nl      The only excuse
  67. \X/    for making a useless thing is that one admires it intensely. -O.W.
  68.